Skip to content

Fade out the last visible paragraph on access-restricted posts#71

Open
bst1n wants to merge 2 commits into
TryGhost:mainfrom
bst1n:public-preview-fade-out-effect
Open

Fade out the last visible paragraph on access-restricted posts#71
bst1n wants to merge 2 commits into
TryGhost:mainfrom
bst1n:public-preview-fade-out-effect

Conversation

@bst1n
Copy link
Copy Markdown

@bst1n bst1n commented Jan 13, 2025

Problem

When a visitor lands on an access-restricted post (members-only, paid, tiers), Ghost truncates the content and renders a CTA below it. Currently the truncated paragraph ends abruptly with no visual signal that more content is hidden.

Solution

A single CSS rule that fades out the last visible paragraph via a mask gradient, scoped strictly to restricted posts (those that contain a .gh-post-upgrade-cta element) using the :has() selector.

.gh-content:has(> .gh-post-upgrade-cta) > p:last-of-type {
    -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%);
    mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%);
}

Why this approach

  • Pure CSS, no HTML changes. No new partial, no wrapper div, no JavaScript.
  • Strictly scoped. Regular posts are completely unaffected — the rule only matches when a .gh-post-upgrade-cta exists as a direct child of .gh-content.
  • Common UX pattern. Medium, Substack, the NYT, etc. all do this. It's become a de-facto standard cue that signals "there's more content behind this paywall".

Browser support

Uses CSS :has() and mask-image. Both are supported in all major browsers since 2023:

  • :has(): Chrome 105+, Safari 15.4+, Firefox 121+
  • mask-image: universal

Overall browser support in late 2026 is ~98%. Visitors on older browsers see the truncated content normally — graceful degradation, no broken layout.

Opt-out

Theme overriders or end users who don't want this effect can disable it with:

.gh-content > p:last-of-type {
    -webkit-mask-image: none !important;
    mask-image: none !important;
}

Replaces previous attempt

This PR was previously a partial-based implementation with several issues (broken file extension, duplicated content, malformed HTML, no i18n). It has been rewritten with the much cleaner CSS-only approach above.

…d posts

Uses a CSS mask gradient on the last <p> child of .gh-content, scoped via
:has() to only apply when a .gh-post-upgrade-cta sibling is present.

This gives readers a visual cue that the article continues beyond the
preview, a common pattern on paywalled content (Medium, Substack, NYT…).
No HTML changes, no new files.
@bst1n bst1n force-pushed the public-preview-fade-out-effect branch from 4f5de34 to cb33a42 Compare May 24, 2026 15:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b96a52de-0495-4634-8c0b-b109be4df98b

📥 Commits

Reviewing files that changed from the base of the PR and between cb33a42 and bf09eaa.

⛔ Files ignored due to path filters (1)
  • assets/built/screen.css.map is excluded by !**/*.map
📒 Files selected for processing (2)
  • assets/built/screen.css
  • assets/css/screen.css
🚧 Files skipped from review as they are similar to previous changes (1)
  • assets/css/screen.css

Walkthrough

Adds a scoped CSS rule targeting .gh-content:has(.gh-post-upgrade-cta) p:last-of-type and applies -webkit-mask-image and mask-image linear-gradient values to fade the last paragraph from bottom to top, indicating truncated access-restricted previews.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a fade-out effect to the last paragraph on access-restricted posts, which is the primary modification in the CSS rule addition.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context about the problem, solution, implementation approach, browser support, and opt-out mechanism for the CSS fade-out feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bst1n bst1n changed the title Public preview fade out effect Fade out the last visible paragraph on access-restricted posts May 24, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@assets/css/screen.css`:
- Around line 2274-2275: The mask gradient on the paragraph is starting at 1%
which fades almost the entire block; update the mask declarations
(-webkit-mask-image and mask-image) to begin the opaque region much lower (e.g.,
change the first color stop from 1% to around 50–70%) so the majority of the
paragraph remains fully readable while only the final portion fades to
transparent; locate the two properties in the CSS and adjust the first stop
percentage to ~60% (or your desired 50–70% value).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 728c61f5-2f07-4a8c-b288-4d11a32b5ef2

📥 Commits

Reviewing files that changed from the base of the PR and between 038f9d6 and cb33a42.

⛔ Files ignored due to path filters (1)
  • assets/built/screen.css.map is excluded by !**/*.map
📒 Files selected for processing (2)
  • assets/built/screen.css
  • assets/css/screen.css

Comment thread assets/css/screen.css Outdated
Address review feedback: the previous 1% start faded almost the entire
paragraph, making most of the preview text hard to read. Starting the
mask at 60% keeps the bulk of the paragraph fully opaque while still
fading the final portion to signal the article continues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant